#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "Serial.h"
#include "Key.h"

uint8_t arr1[] = {0x01, 0x02, 0x03, 0x04, 0x05};
uint8_t RxData = 0;
uint8_t i = 0;

int main(void)
{
	Key_Init();
	OLED_Init();
	Serial_Init();
	OLED_ShowString(1, 1, "Hello Bird!");
	OLED_ShowString(2, 1, "IX:");
	OLED_ShowString(3, 1, "RX:");
	//Serial_SendArray(arr1, 5);
	//Serial_SendString("Hello Wang Yi Ming!");
	//Serial_SendNum(12345, 5);
	//printf("Wang's Age = %d\n", 20);
	//Serial_Printf("王一鸣我爱你\r\n");

	Serial_TXPack[0] = 0x00;
	Serial_TXPack[1] = 0x01;
	Serial_TXPack[2] = 0x02;
	Serial_TXPack[3] = 0x03;

	while (1)
	{
		if (Key2_In() == 2)
		{
			for (i = 0; i < 4; i++)
			{
				Serial_TXPack[i]++;
				OLED_ShowHexNum(2, 3 * i + 4, Serial_TXPack[i], 2);
			}
			Serial_SendHexPacket();
		}
		if (Serial_GetRxFlag() == 1)
		{
			for (i = 0; i < 4; i++)
			{
				OLED_ShowHexNum(3, 3 * i + 4, Serial_RXPack[i], 2);
			}
		}

	}
}
